﻿#pragma once

#include <learn/dll_ext.h>
#include <string>

namespace xi
{

namespace topo
{

class Property_Base
{
  public:
    /**
     * @brief 基本构造
     *
     * @param[in] name
     */
    Property_Base(std::string name) : m_name(name)
    {
    }

    /**
     * @brief 空析构
     *
     */
    virtual ~Property_Base() = default;

    /**
     * @brief 返回属性名
     *
     * @return constexpr std::string
     */
    constexpr std::string name() const noexcept
    {
        return m_name;
    }

  protected:
    std::string m_name;
};

template <typename T, typename Ty> class Property_Handle : public Property_Base
{
  public:
    /**
     * @brief 基本构造
     *
     * @param[in] name
     */
    Property_Handle(std::string name) : Property_Base(name), m_t(T{})
    {
    }

    /**
     * @brief 返回属性值
     *
     * @return constexpr const T&
     */
    constexpr const T &property() const noexcept
    {
        return m_t;
    }

    /**
     * @brief 返回属性值
     *
     * @return constexpr T&
     */
    constexpr T &property() noexcept
    {
        return m_t;
    }

  protected:
    T m_t;
};

} // namespace topo

} // namespace xi
